@extends('pop')
@section('content')

<body>

<blockquote class="layui-elem-quote layui-text">
  添加管理员注意添加信息
</blockquote>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>添加管理员</legend>
</fieldset>

<form class="layui-form" action="" enctype="multipart/form-data" id="form">
  @csrf
  <div class="layui-form-item">
    <label class="layui-form-label">登录名</label>
    <div class="layui-input-block">
      <input type="text" name="login_name" lay-verify="required" lay-reqtext="登录名是必填项，岂能为空？" placeholder="请输入登录名" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-block">
      <input type="password" name="password" lay-verify="required" lay-reqtext="密码是必填项，岂能为空？" placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">验证手机</label>
      <div class="layui-input-inline">
        <input type="tel" name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input">
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">验证邮箱</label>
      <div class="layui-input-inline">
        <input type="email" name="email" lay-verify="email" autocomplete="off" class="layui-input">
      </div>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">爱好</label>
    <div class="layui-input-block">
      <input type="checkbox" name="like[write]" title="写作">
      <input type="checkbox" name="like[read]" title="阅读">
      <input type="checkbox" name="like[game]" title="游戏">
    </div>
  </div>


  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit=""  >立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>


<script>
    $.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}});
    $('#form').submit(function(event) {
        //alert(111);
        //ajax方式提交form表单信息给服务器
        event.preventDefault(); //阻止浏览器form表单提交
        var form = document.getElementById("form");
        var fd = new FormData(form);
        $.ajax({
            url:'/admin/adminAdd',
            type:'post',
            data:fd,
            processData:false,
            contentType:false,
            dataType:'json',
            success:function(res){
                if(res.code==1){
                    parent.window.location.href = parent.window.location.href;
                }else{
                    layer.alert(res.msg,{icon:5});
                }
            }
        })
    })

</script>

</body>
@endsection